package com.securitydemo.service.impl;

import com.securitydemo.converter.UserConverter;
import com.securitydemo.dao.IUserDao;
import com.securitydemo.dao.entity.UserEntity;
import com.securitydemo.securitylogin.LoginUser;
import com.securitydemo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    IUserDao userDao;

    @Override
    public LoginUser getUserByUsername(String username) {
        return UserConverter.from(userDao.findUserEntitiesByUsername(username));
    }

    @Override
    public String registerLogin(UserEntity userEntity) {
        userDao.save(userEntity);
        return "success";
    }
}
